<?php
/**
 * Created by PhpStorm.
 * User: 钊鑫
 * Date: 2019/1/26
 * Time: 11:49
 */
namespace app\api\model;

use app\api\model\Category as CategoryModel;

class Project extends Base
{
    protected $hidden = ['parent_id','teacher'];
    protected $insert = ['auditing_1' => 0,'auditing_2' => 0,'publish'=>1];
    protected $type = [
        'params'    =>  'json',
        'field'     =>  'array',
    ];
    protected $autoWriteTimestamp = true;                           //自动时间戳

    //院系转换
    public function getcollegeAttr($value){
        return categoryModel::where(['id'=>$value,'publish'=>'1'])->value('title');
    }

    //下载文件
    public function getfilesAttr($value){
        return 'http://srms.telecomlab.cn/ZZX/cxcyxy2/'.$value;
    }

    //关联Homeuser
    public function detail(){
        return $this->hasOne('Homeuser','id','parent_id');
    }


}